#include "EPSG/DirectionalLight.h"

/* System Includes */
#ifdef WIN32
	#include <Windows.h>
#endif

/* OpenGL Includes */
#include <GL/GL.h>
#include <GL/GLU.h>

EPSG::DirectionalLight::DirectionalLight()
{
	_dir[0] = 0;
	_dir[1] = 0;
	_dir[2] = 1;
	_dir[3] = 0;
}

void EPSG::DirectionalLight::setupLights()
{
	if( !_enabled )
	{
		glDisable( GL_LIGHT0 + _id );
		return;
	}

	glPushMatrix();
	_parent->setupLights();

	glLightfv( GL_LIGHT0 + _id, GL_POSITION, _dir );
	glLightfv( GL_LIGHT0 + _id, GL_AMBIENT , _amb );
	glLightfv( GL_LIGHT0 + _id, GL_DIFFUSE , _dif );
	glLightfv( GL_LIGHT0 + _id, GL_SPECULAR, _spc );

	glEnable( GL_LIGHT0 + _id );
	glPopMatrix();
}

void EPSG::DirectionalLight::setDirection( float x, float y, float z )
{
	_dir[0] = x;
	_dir[1] = y;
	_dir[2] = z;
	_dir[3] = 0;
}